package com.cungmua.app.activity;

import android.os.Bundle;
import android.widget.TextView;
import android.widget.Toast;

import com.cungmua.app.R;
import com.cungmua.app.base.BaseDrawerActivitys;
import com.cungmua.app.handler.OrderDetailsHandler;
import com.cungmua.app.model.OrderDetails;
import com.cungmua.app.model.request.OrderDetailsRequest;
import com.cungmua.app.model.response.OrderDetailsResponse;
import com.cungmua.app.task.OrderDetailTask;

/**
 * Created by kelvin.nguyen on 7/23/14.
 */
public class OrderDetailsActivity extends BaseDrawerActivitys implements OrderDetailsHandler{
    private int currentOrderId;
    private TextView txtMadh;
    private TextView txtCreateDate;
    @Override
    public int getLayoutResource() {
        return R.layout.activity_order_detail;
    }

    @Override
    public void updateView() {
        super.updateView();
        OrderDetailsRequest request=new OrderDetailsRequest(getDeviceId(),getToken());
        request.setUserId(getCurrentUser().getId());
        request.setOrderId(currentOrderId);

        OrderDetailTask task=new OrderDetailTask(this,this);
        task.execute(request);

    }

    @Override
    public void loadControls(Bundle savedInstanceState) {
        super.loadControls(savedInstanceState);

        currentOrderId= getIntent().getExtras().getInt(IK_ORDER_ID);

        txtMadh=(TextView)findViewById(R.id.txtMadh);
        txtCreateDate=(TextView)findViewById(R.id.txtCreateDate);

    }


    @Override
    public void onOrderDetail(OrderDetailsResponse orderDetailsResponse) {
        OrderDetails orderDetails= orderDetailsResponse.getData();
        txtMadh.setText(getResources().getString(R.string.label_madonhang)+"#"+currentOrderId);
//        txtCreateDate.setText(AppUtils.get);



        Toast.makeText(this, orderDetailsResponse.getData().getAmountTotal() + "", Toast.LENGTH_LONG).show();
    }
}
